package servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import dao.CheckDao;
import dao.WaresDao;
import dao.impl.ICheckDao;
import dao.impl.IWaresDao;

public class PayServelt extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doPost(request,response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		
		
		String username = (String)request.getSession().getAttribute("username");
		String address = request.getParameter("address");
		String tel = request.getParameter("tel");
			CheckDao cd = new ICheckDao();
			boolean flag  = cd.UpUser(username, address, tel);
			if (flag) {
				WaresDao wd = new IWaresDao();
				boolean b =wd.PayCar(username);
				if (b) {
					response.sendRedirect("paysuccess.jsp");
				}
			}
	}
}
